<template>
    <div class="list_page_div">
		<page-list :loading="loading" :table-config="tableConfig" :data-list="dataList" :height="height" show-index
				   show-page :total="total" :currentPage="param.pageNum" :pageSize="param.pageSize" @currentChange="handleCurrentChange"
				   show-operate operate-width="120px">
            <template #searchArea>
                <el-input v-model="param.approveCode" clearable placeholder="流程编号" style="width: 200px;"></el-input>
                <el-input v-model="param.approveName" clearable placeholder="流程名称" style="width: 200px;"></el-input>
                <el-button type="primary" @click="searchList">查询</el-button>
                <el-button type="primary" @click="resetData">重置</el-button>
                <el-button type="primary" @click="editData()">新增</el-button>
            </template>

            <template #operateContent="scope">
                <el-button type="text" @click="editData(scope.row.id)">编辑</el-button>
                <el-popconfirm title="是否确定删除当前数据？" @confirm="delData(scope.row.id)">
                    <el-button slot="reference" type="text">删除</el-button>
                </el-popconfirm>
            </template>
        </page-list>
        <!-- 编辑页 -->
        <flow-type-edit :visible.sync="showEdit" :id="id" @refreshList="searchList"></flow-type-edit>
    </div>
</template>

<script>
import PageList from "@/components/grid/pageList";
import FlowTypeEdit from "./compnent/flowTypeEdit";

export default {
    name: "flowTypeList",
    components: {FlowTypeEdit, PageList},
    data() {
        return {
            height: '500px',
            loading: false,
            showEdit: false,
            
            id: '',
            tableConfig: [
                {label: "流程编号", prop: "flowableCode", width: 160},
                {label: "流程名称", prop: "flowableName", minWidth: 200},
                {label: "处理类名", prop: "className", width: 220},
                {label: "处理方法", prop: "dealMethod", width: 160},
                {label: "提交方法", prop: "applyMethod", width: 160},
                {label: "通过方法", prop: "adoptMethod", width: 160},
                {label: "拒绝方法", prop: "rebutMethod", width: 160},
                {label: "撤回方法", prop: "recallMethod", width: 160},
            ],
            dataList: [],
            total: 0,
            param: {
                approveCode: '',
                approveName: '',
                field: 'create_time',
                order: 'desc',
                pageSize: 20,
                pageNum: 1,
            }
        }
    },
    mounted() {
        this.$nextTick(() => {
            this.height = (document.body.offsetHeight - 185) + "px";
        })
        this.searchList();
    },
    methods: {
        handleCurrentChange(val) {
            this.param.pageNum = val;
            this.searchList();
        },
        resetData() {
            this.param.approveCode = '';
            this.param.approveName = '';
            this.param.pageNum = 1;
            this.searchList();
        },
        searchList() {
            this.loading = true;
            this.$axios.post("/CHILD_SYSTEM/baseFlowType/getPageList", this.param).then(res => {
                this.total = res.data.total;
                this.dataList = res.data.rows;
            }).finally(() => {
                this.loading = false;
            })
        },
        editData(id) {
            this.id = id;
            this.showEdit = true;
        },
        delData(id) {
            this.loading = true;
            this.$axios.post("/CHILD_SYSTEM/baseFlowType/delete/" + id).then(res => {
                this.searchList();
                this.$message.success(res.message);
            }).finally(() => {
                this.loading = false;
            })
        }
    }
}
</script>

<style scoped>

</style>